/*create by 2017/07/10 头部list公共组件*/
import React from "react";
import Relay from 'react-relay';
import { message } from 'antd';
import '../css/style.css';

export default class headerList extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            proWorkShopList: [],
            current: 0
        }
        this.enterpriseId = sessionStorage.getItem('enterpriseId');
    }
    // componentWillMount() {
    //     this.getworkList()
    // }
    // getworkList() {
    //     Relay.Store.commitUpdate(
    //         new FindProWorkShopMutation({
    //             enterpriseId:this.enterpriseId,
    //         }),
    //         {
    //             onFailure: () => {
    //                 message.error('网络请求失败');
    //             },
    //             onSuccess: (response) => {
    //                 let data = response.findProWorkShop.findProWorkShop;
    //                 if(data.errorCode=='0'){
    //                     this.setState({
    //                         proWorkShopList: data.proWorkShopList
    //                     })
    //                 } else {
    //                     message.error(data.value);
    //                 }
    //             }
    //         }
    //     )
    // }
    listClick(workShopId, i){
        this.setState({
            current: i
        })
        this.props.workGroupClick(workShopId)
    }
    render() {
        const { proWorkShopList,current } = this.state;
        return(
            <div className="statistics_com_headerList">
                <ul>
                    {
                        proWorkShopList && proWorkShopList.length ? proWorkShopList.map((v,i)=>{

                            return <li className={ i == current ? 'active' : ''} onClick={this.listClick.bind(this, v.workShopId, i)}>{v.name}</li>
                        }) : null
                    }
                </ul>
            </div>
        )
    }
}